// Copyright 2011 Bryan McKelvey, MIT License

/**
 * @fileoverview Methods for the popup
 * @author bryan.mckelvey@gmail.com (McKelvey Bryan)
 */

/**
 * A handful of methods for the popup
 * @constructor
 */
var Popup = (function(){
	/**
	 * Retrieves the background page
	 * @type function
	 */
	var bg = chrome.extension.getBackgroundPage();
	
	/**
	 * Determines the natural width of the page
	 * @type number
	 * @deprecated
	 */
	var naturalWidth = 0;
	
	/**
	 * Updates the quote table
	 * @returns The current object
	 * @type Popup
	 */
	function updateTable() {
	  bg.Investor.current().updateTable(tbl);
		return Popup
	}

	return {
		/**
		 * Loads the popup, calling the methods to localize the page and draw
		 * all of the elements
		 * @return The current object
		 * @type Popup
		 */
		load: function(){
			bg.Localizer.localize($(document));
		  if (bg.Investor.current() == undefined) {
		    bg.Investor.reset();
		  }
		  bg.Investor.createDropDown($('#dropdown')[0], $('#table')[0], false);
		  bg.Investor.drawTable($('#table')[0]);
		  bg.Sources.$div = $('#chart');
		  setInterval(updateTable, 2000);
			return this;
		}
	}	
})();

Popup.load();
